﻿#pragma once

#include <qtreewidget.h>
#include <qvector.h>

class ScriptInstruction;
class ScriptRunner;

class TreeWidget_DisplayScriptList : public QTreeWidget
{
  Q_OBJECT

private:
  QTreeWidgetItem* lastHighLightNode = Q_NULLPTR;//记录上一个高亮的item
  QVector<QTreeWidgetItem*> codeBlockItems;//用于记录每个循环对应的item，在高亮当前指令时需要用到
  ScriptRunner* scriptRunner= Q_NULLPTR;
public:
  TreeWidget_DisplayScriptList(QWidget *parent = Q_NULLPTR);
  ~TreeWidget_DisplayScriptList();
private:
  void circularDelete(QTreeWidgetItem* parent);
public slots:
  void slot_showCurrentInstruction(int codeBlockIndex, int instructionIndex);
  void slot_clearCurrentInstruction();
  void slot_updateScriptList(QVector<QVector<ScriptInstruction*>> scriptList);
public:
  ScriptRunner* getScriptRunner();
  void setScriptRunner(ScriptRunner* scriptRunner);
};
